using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Navigation;
namespace MicroMsg.UI.Page
{
	public class ChoosePeopleToShareContent : ChatContainerPage
	{
		private const string TAG = "ChoosePeopleToShareContent";
		private string strShareContentToken = "";
		private bool isFirstIn = true;
		private ApplicationBar mBar;
		private ApplicationBarIconButton OkMenuBtn;
		private List<UIElement> mUiToHideList;
		internal Grid LayoutRoot;
		internal Grid LayoutContent;
		internal panelTitle2Line panelTitle;
		internal TextBlock shareTxt;
		internal Grid ContentPanel;
		internal ContactsView mContactView;
		private bool _contentLoaded;
		public ChoosePeopleToShareContent()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.ChoosePeopleToShareContent_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.ChoosePeopleToShareContent_Unload));
		}
		private void ChoosePeopleToShareContent_Loaded(object sender, RoutedEventArgs e)
		{
			this.shareTxt.set_Text(strings.Reader_Share_To_Album_Title);
			ContactsView.resetCheckedList();
			Log.smethod_5("ChoosePeopleToShareContent", "page count = " + PageManager.getInstance().GetPageCount().ToString());
			if (PageManager.getInstance().GetPageCount() >= 1)
			{
				PageManager.getInstance().PopPage();
			}
		}
		private void ChoosePeopleToShareContent_Unload(object sender, RoutedEventArgs e)
		{
		}
		protected override void OnPageIn(object[] object_0)
		{
		}
		protected override void OnNavigatedTo(NavigationEventArgs navigationEventArgs_0)
		{
			IDictionary<string, string> queryString = base.get_NavigationContext().get_QueryString();
			if (queryString.ContainsKey("FileId"))
			{
				this.strShareContentToken = queryString.get_Item("FileId");
				Log.smethod_5("ChoosePeopleToShareContent", "ShareContent FileId = " + this.strShareContentToken);
			}
			this.mContactView.initForAddPeoplePage();
			ContactsView.resetCheckedList();
			if (this.isFirstIn)
			{
				base.set_ApplicationBar(this.GetApplicationBar());
				this.isFirstIn = false;
			}
		}
		private ApplicationBar GetApplicationBar()
		{
			if (this.mBar != null)
			{
				return this.mBar;
			}
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			if (this.mBar != null)
			{
				this.mBar.set_BackgroundColor(((SolidColorBrush)R.theme.COMMON_APPBAR_BK_BRUSH).get_Color());
				this.mBar.set_ForegroundColor(((SolidColorBrush)R.theme.COMMON_APPBAR_FG_BRUSH).get_Color());
			}
			this.OkMenuBtn = new ApplicationBarIconButton(new Uri("/icons/appbar.check.rest.png", 2));
			this.OkMenuBtn.set_Text(strings.COM_Confirm);
			this.OkMenuBtn.add_Click(new EventHandler(this.OkMenuBtn_Click));
			this.OkMenuBtn.set_IsEnabled(false);
			this.mBar.get_Buttons().Add(this.OkMenuBtn);
			return this.mBar;
		}
		private void OkMenuBtn_Click(object sender, EventArgs e)
		{
			List<Contact> checkedItem = ContactsView.getCheckedItem();
			if (checkedItem == null || checkedItem.get_Count() <= 0)
			{
				MessageBoxManager.ShowToast(strings.ChatAddPeopleSelectAlert, 2500, null, false);
				return;
			}
			if (checkedItem.get_Count() == 1)
			{
				ChatContainerPage.GoToChatPage(this, checkedItem.get_Item(0).strUsrName, null, null, this.strShareContentToken);
				return;
			}
			string text = "";
			for (int i = 0; i < checkedItem.get_Count() - 1; i++)
			{
				if (!(checkedItem.get_Item(i).strUsrName == AccountMgr.getCurAccount().strUsrName))
				{
					text += checkedItem.get_Item(i).strUsrName;
					text += ";";
				}
			}
			text += checkedItem.get_Item(checkedItem.get_Count() - 1).strUsrName;
			base.GoToPage("/Source/Plugin/MassSend/UI/SendMessagePage.xaml", new object[]
			{
				text,
				(uint)checkedItem.get_Count(),
				false,
				this.strShareContentToken
			}, true);
		}
		private void ItemCheckChanged(object sender, object object_0)
		{
			this.CheckItemChange();
		}
		private void CheckItemChange()
		{
			List<Contact> checkedItem = ContactsView.getCheckedItem();
			if (checkedItem.get_Count() == 0)
			{
				this.OkMenuBtn.set_IsEnabled(false);
				return;
			}
			this.OkMenuBtn.set_IsEnabled(true);
		}
		public override List<UIElement> GetBkContents()
		{
			if (this.mUiToHideList == null)
			{
				this.mUiToHideList = new List<UIElement>();
				this.mUiToHideList.Add(this.LayoutContent);
			}
			return this.mUiToHideList;
		}
		public override Panel GetChatContainerPanel()
		{
			return this.LayoutRoot;
		}
		protected override void resumeFromChat()
		{
			this.mContactView.Focus();
			UIDelayService.getInstance().DoDelayAction();
		}
		protected override void OnBackKeyPress(CancelEventArgs cancelEventArgs_0)
		{
			base.OnBackKeyPress(cancelEventArgs_0);
		}
		protected override void OnPageOut()
		{
			base.PreOnPageOut();
		}
		protected override void OnPageForward(Uri targetPage)
		{
			base.PreOnPageForward(targetPage);
		}
		protected override void OnPageBack()
		{
			base.PreOnPageBack();
		}
		private void Button_Click(object sender, RoutedEventArgs e)
		{
			object[] object_ = new object[]
			{
				this.strShareContentToken
			};
			base.GoToPage("/Source/Plugin/Sns/Common/UI/UploadAndPost/SnsPostPage.xaml", object_, true);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/ChoosePeopleToShareContent.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.LayoutContent = (Grid)base.FindName("LayoutContent");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.shareTxt = (TextBlock)base.FindName("shareTxt");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.mContactView = (ContactsView)base.FindName("mContactView");
		}
	}
}
